home *** CD-ROM | disk | FTP | other *** search
/ The Original Shareware 1.1 / The Original Shareware (WeMake CDs)(Volume 1.1)(CDs, Inc)(1993).iso / 36 / spawn15.zip / UTIL.DOC < prev   
Text File  |  1990-11-01  |  15KB  |  341 lines

  1.                              SPAWN UTILITIES
  2.                      Copyright 1990, Albert H. Ariail
  3.  
  4.  
  5.                            DVTEST  version 1.0
  6.  
  7. Dvtest is a simple program that displays a message stating whether or not
  8. Desqview is active.  If so, the current application name and number are
  9. listed.  More importantly, dvtest exits setting the dos return code as
  10. follows:
  11.  
  12. 0     desqview is not active
  13. nonzero  desqview is active. return code set to current application number
  14.  
  15. This way you may use an "if errorlevel" test to make batch files desqview
  16. specific or desqview aware.  A particular example, of a sort that I
  17. actually use is as follows:
  18.  
  19. dvtest >nul
  20. if not errorlevel 1 goto nodv
  21. spawn/d/f/x/p:ed c:\bin\edit.exe %1
  22. goto stop
  23. :nodv
  24. c:\bin\edit.exe %1
  25. :stop
  26.  
  27. If desqview is active, the program is loaded in its own window as 
  28. determined by the pif file ed-pif.dvp, otherwise, the program is just
  29. executed.  With the current version of spawn, you could just invoke
  30. spawn, both inside and outside desqview.  This method will save a bit
  31. of memory, however, when used outside of desqview.
  32.  
  33.  
  34.                          RELEASE.COM  Version 1.0
  35.  
  36. This program provides a way to pass a byte return code from batch file
  37. started by spawn.  In order for spawn to process a return code, it
  38. must be waiting to receive one, ie, you must use spawn/w . Given this,
  39. then in the batch program started by spawn if you include the statement:
  40. release 3
  41. spawn will exit with a dos return code of 3.
  42. Processing continues as normal in the child process.
  43. If you do not include any argument, release assumes a value of 0.
  44. This program will only function with desqview active.
  45.  
  46.  
  47.                            KILL.COM Version 1.0
  48.  
  49. This program allows you to close the current desqview window, or another
  50. window for which you have a "process handle".
  51.  
  52. First, to close the window in which kill is executed, enter
  53.  
  54. kill
  55.  
  56. The action of kill is more like selecting "Close Window" from the 
  57. desqview menu, or keying Ctrl-Alt-Del.  The current window is just 
  58. closed, without any clean up.  This is generally safe, at least, in a 
  59. batch file.  The only side effect of this that I have found is that under 
  60. certain circumstances, 4dos will dribble "swap" files around.
  61.  
  62. To close another window, enter
  63.  
  64. kill HANDLE
  65.  
  66. where HANDLE is a window specifier described below.  When used in this
  67. manner, no action is take to inform spawn that a window is being closed.
  68. If spawn is waiting for a return code, it will just sit there until you
  69. abort the wait by keying ESC.
  70.  
  71. The window handle can be given as an 4 byte hexadecimal number in the 
  72. format ?hhhhhhhh . This is not very useful, but is included for 
  73. completeness.  Otherwise you may use a symbolic name for the parameter
  74. such as:
  75.  
  76. kill PARENT
  77.  
  78. Kill will search the DOS environment for a handle listed under the
  79. specified name.  If a valid desqview handle is found, the window it
  80. represents will be summarily dispatched.  It just so happens that when
  81. spawn starts a process, it installs an entry of just this sort called 
  82. "PARENT" in the child's environment, which can be used for this purpose. 
  83.  
  84. If the argument specified is not found in the environment, kill uses the 
  85. argument as a file name and tries to find the correct handle by reading 
  86. its contents.  You may use spawn/n to create such a file, as in 
  87.  
  88. spawn/n ... >child
  89.  
  90. then the command "kill child" will terminate the specified process.
  91.  
  92. While all of this may satisfy some of your latent homicidal tendencies,
  93. it isn't of any great utility.  A more satisfying application of kill
  94. is provided below, in conjunction with the program ALERT.
  95.  
  96. Using fixed "temporary" files in this manner in a multitasking 
  97. environment can cause a bit of unpleasantness.  It is possible that
  98. some day you may start the same batch process twice.  The second process
  99. will overwrite the same file "child", and when the first process hits
  100. the "kill" part, it will promptly shut down the wrong process.  This may
  101. or may not be a major disaster, depending on who is doing what to whom.
  102.  
  103. If you are using 4dos, there is a better way.  4dos has an internal
  104. function "INPUT" which copies text from standard input to an environment
  105. variable.  Since the environment is local to each process, you will not
  106. have this sort of problem.  For example,
  107.  
  108. spawn /n mytask | input %%child
  109. ...
  110. kill child
  111.  
  112. This is one example of about 1000 ways in which 4dos is better behaved 
  113. that command.com .  There are, I believe, public domain utilities that
  114. purport to do this sort of thing with a standard DOS system.  I do not 
  115. know if any of them work, especially with desqview, but if you can find
  116. one that does, using it for this would be recommended.
  117.  
  118.  
  119.                           ALERT.EXE Version 1.0
  120.  
  121. Alert is general purpose "error message" / "status message" utility . It 
  122. has be primarily designed as a means in which batch processes can display 
  123. status or request operator intervention, even though they are running in 
  124. a desqview window which is not currently visible.  ALERT by no means 
  125. requires desqview to function, however.  You may wish to use it as well 
  126. outside of desqview as a fancy version of the DOS command "pause". 
  127.  
  128. INSTALLATION (Read me, Please)                           
  129. Since desqview is not required to use Alert, you may wish to copy the
  130. executable file into a standard dos directory, such as \bin, rather than
  131. hiding it away in \dv .  When you are using Alert with desqview, you
  132. configure 1K of "system memory" in any window which may use Alert.  If
  133. you do not, you will have to respond to a non-fatal but irritating error
  134. message when Alert is invoked.    If this is not convenient, the switch
  135. options (/a/t/s) do not require any system memory.
  136.  
  137. Command Syntax:
  138.  
  139. Alert [/x] "message"
  140.  
  141. The quotation marks are not really required, but if you do not include
  142. them, Alert (actually Turbo-C) will strip white space for you.
  143. In Desqview, Alert will create a small window containing the message,
  144. punch it through to the foreground and wait for you to respond.  You may
  145. acknowledge a message by pressing any key, or clicking the mouse.  Please
  146. note that, in Desqview, the mouse cursor must be inside the message 
  147. window in order for the mouse to work.  Otherwise, you will be telling 
  148. desqview to push the message window back into the background (something 
  149. you may also want to do on occasion). 
  150.  
  151. Options: 
  152.  
  153. /h     display help
  154.      as you might expect, this displays a brief summary
  155.      of the option available with this program
  156.  
  157. /q     quiet alarm
  158.      beeps the speaker. Alert is silent by default.
  159.  
  160. /l:tune  loud alarm
  161.      really beeps the speaker. The tune to play is a list of
  162.      numbers in the format: freq,duration;freq,duration;...
  163.      the duration is measured in "tics" (about 18 milliseconds).
  164.      The maximum length is 32 freq,duration pairs.    The default
  165.      tune is: 450,4;500,4;550,4;500,4;450,4
  166.  
  167. /m     ignore mouse
  168.      this should seldom be needed with desqview, but is included
  169.      to prevent conflicts with menu software and the like.
  170.  
  171. /w:n     this displays the message text for n seconds or until
  172.      any key is pressed .  The message window will be in
  173.      the foreground and will have possession of the keyboard
  174.      /w:0 (the default) will wait forever
  175.  
  176. /d:n     display message for n seconds
  177.      this also displays the message for n seconds, but does not
  178.      look at the keyboard or the mouse (and does not own them).
  179.      /d or /d:0 will cause alert to exit leaving the message
  180.      window intact.  In desqview, the message will be redisplayed
  181.      every time you switch to the window which ran alert.
  182.  
  183. /a    alternate format
  184.     this uses a different method for displaying the error window.
  185.     It has primarily been included because in desqview no
  186.     "system memory" is required.  You cannot control the color,
  187.     position, or the keyboard usage.  To respond to a /a format
  188.     message, key ESC or click the mouse.  One additional use of
  189.     this method is that since the error window is always displayed
  190.     in the upper left corner of the window in question, /a will
  191.     allow you to post a message that is closely associated with
  192.     a given window.  This is useful if there are a number of small
  193.     desqview windows on the display.
  194.  
  195. /t    this is brain dead format.
  196.     The text message is just printed using standard dos channels.
  197.     This is supplied in case you have a need to use a 30k program
  198.     to simulate the function of the DOS internal command "pause".
  199.     Well, that's not completely true.  Pause won't whistle dixie or
  200.     respond to the mouse.
  201.  
  202. /s    use bios only.
  203.     when this is specified outside of desqview, this cause the
  204.     display routines to use the video bios rather that manipulating
  205.     the display hardware directly.    This may be needed on some machines.
  206.     Inside desqview, this option causes alert to ignore the desqview
  207.     window manager and function as though desqview were not present.
  208.  
  209. /p:n    uses physical attribute n (hex)
  210.     controls the color of the message, the default is a boring
  211.     white on black (see note on this below).
  212.  
  213. /r:n    position (row) of message window
  214.     the default is 1
  215.  
  216. /c:n    position (col) of message window
  217.     the default is selected to center the message text on the display.
  218.     Outside of desqview, alert will support more than 80 columns.
  219.     At this writing, desqview is a bit twitchy about doing that, so
  220.     I don't recommend that you use more than 80 columns inside
  221.     desqview.
  222.  
  223. /k:ab    keys to accept $=esc @=enter ?=any 1,2=mouse
  224.     This represents a list of the keys that will be accepted to
  225.     acknowledge the message. Case is not considered.  Any key
  226.     not on the list is ignored.  You may use the special characters
  227.     listed to represent some of the non-alphabetic keys. A space can
  228.     be included, but you should enclose the entire parameter in
  229.     quotes, eg, "/k: abc$"
  230.  
  231. /f    switch to the foreground
  232.     This switches the entire process calling Alert into the
  233.     foreground.  Normally, only the message window will go to
  234.     the foreground
  235.  
  236. /b    stay in the background
  237.     The message will go to the top of the application calling Alert
  238.     but not necessarily all the way to the foreground.  If the Alert
  239.     window is behind some other window, you will have to switch to
  240.     the alert window to see the message.
  241.  
  242. /n    output window handle
  243.     This only works with /d (or /d:0) since that is the only time
  244.     a window remains behind after alert exits.  The window handle
  245.     is compatible with kill.com, which can be used to remove the
  246.     message window, as in
  247.     alert /n /d "hello world" >handle
  248.     ...
  249.     kill handle
  250.  
  251. /z      exit with background operation disabled
  252.         alert normally requires the window in which it is executing to
  253.         have background operation enabled.  Alert will automatically set
  254.         this, but will leave it enabled.  If this causes a problem, you
  255.         can use this option to tell alert to set the background flag to
  256.         disabled just before it exits
  257.  
  258. Notes:
  259.  
  260. 1.  Format switches
  261.     The switches /d /w /t and /a are mutually exclusive.  If you include
  262.     more than one of these, only the last will have any effect. If no 
  263.     format switch is included, /w:0 is assumed 
  264.  
  265. 2.  Behavior outside of Desqview.
  266.     Most of the features of the program will work without desqview. There 
  267.     are some format differences and, since, I do not have available 
  268.     Desqview's powerful screen virtualization capabilities, /d:0 will not 
  269.     work the same.  But the simulation is close enough so that you can
  270.     put Alert calls into batch files without being overly concerned about
  271.     what will happen if they are ever executed outside of desqview.
  272.     The options /n /f /b /z  have no meaning whatever without desqview and 
  273.     are ignored.
  274.  
  275. 3.  For best results with /d
  276.     Using /d to display status messages will work better if the 
  277.     foreground window (that is, the window in which you are working, not 
  278.     the window which calls alert) has "runs in the background" set to 
  279.     "y".  If this is done, the original program will not lose control
  280.     of the keyboard.  Otherwise, you will have to click the working
  281.     window fully into the foreground to continue.
  282.     
  283.     In addition, if "writes directly to the screen" is set to "n", or
  284.     "virtualize text" is on in the foreground window, the message window
  285.     will not scroll off, but instead, the foreground text will scroll
  286.     underneath the message window.
  287.  
  288. 6   Color problems
  289.     The default color for the message window is /p:07 (white on black).
  290.     This value is used instead of something more interesting because
  291.     of the way desqview handles color mapping in windows with "uses
  292.     its own colors" set to "n".  In this case alert will display the
  293.     message window with the same colors as the parent window.  When
  294.     using /p:n, in this case, desqview will map the colors into something
  295.     which is usually just awful. The only way to get true colors is to
  296.     start alert with something like:
  297.     spawn/w alert -p:31 "hello"
  298.  
  299. 5.  The keyboard filter and return codes.
  300.     /d always exits with a return code of 0. If /k is not used
  301.     alert will exit with a return code equal to the ascii code of
  302.     the key that was pressed or '1'/'2' for the mouse.  If /w:n times
  303.     out without a keypress, alert sets the return code to 0.  Non 
  304.     Ascii keys (such as Fkeys) set the return code to -x, where x
  305.     is the byte value of the bios scan code for the key that was used.
  306.     This is a little complex, but usable if you can figure out just
  307.     what the heck "minus the bios scan code" is.
  308.     
  309.     /k is bit easier to use.  /k will exit with a return code equal to 
  310.     the position of the key in the specified list. For example, if you
  311.     use /k:abcd and respond with "C", alert will exit with a return
  312.     code of 3 . You can then use "if errorlevel" tests to make the
  313.     batch file do different things.  Remember, "if errorlevel 3" means
  314.     "if the return code is 3 or higher" so you will have to process you
  315.     return codes from highest to lowest, eg.
  316.  
  317.     alert -w:10 /k:abcd? "hello world"
  318.     if errorlevel 5 goto key_any
  319.     if errorlevel 4 goto key_d
  320.     if errorlevel 3 goto key_c
  321.     if errorlevel 2 goto key_b
  322.     if errorlevel 1 goto key_a
  323.     goto nokey
  324.  
  325.     If you frequent PC magazine, you may recall a neat trick for
  326.     making this sort of stuff a little more elegant
  327.  
  328.     for %%d in (5 4 3 2 1 0) do if errorlevel %d goto key_%d
  329.     goto nokey
  330.     
  331.     :key_0
  332.     ...
  333.     :key_1
  334.     ...
  335.     :nokey
  336.  
  337.     If I have done my job right (I don't always) the last "goto nokey"
  338.     will never be executed.  
  339.  
  340.     Enjoy.  AHA
  341.